package com.ruoyi.record.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.record.domain.Recordtype;
import com.ruoyi.record.service.IRecordtypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 跟进类型Controller
 * 
 * @author dj
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/recordtype/recordtype")
public class RecordtypeController extends BaseController
{
    @Autowired
    private IRecordtypeService recordtypeService;

    /**
     * 查询跟进类型列表
     */
    @PreAuthorize("@ss.hasPermi('recordtype:recordtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(Recordtype recordtype)
    {
        startPage();
        List<Recordtype> list = recordtypeService.selectRecordtypeList(recordtype);
        return getDataTable(list);
    }

    /**
     * 导出跟进类型列表
     */
    @PreAuthorize("@ss.hasPermi('recordtype:recordtype:export')")
    @Log(title = "跟进类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Recordtype recordtype)
    {
        List<Recordtype> list = recordtypeService.selectRecordtypeList(recordtype);
        ExcelUtil<Recordtype> util = new ExcelUtil<Recordtype>(Recordtype.class);
        util.exportExcel(response, list, "跟进类型数据");
    }

    /**
     * 获取跟进类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('recordtype:recordtype:query')")
    @GetMapping(value = "/{recordTypeId}")
    public AjaxResult getInfo(@PathVariable("recordTypeId") Long recordTypeId)
    {
        return success(recordtypeService.selectRecordtypeByRecordTypeId(recordTypeId));
    }

    /**
     * 新增跟进类型
     */
    @PreAuthorize("@ss.hasPermi('recordtype:recordtype:add')")
    @Log(title = "跟进类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Recordtype recordtype)
    {
        return toAjax(recordtypeService.insertRecordtype(recordtype));
    }

    /**
     * 修改跟进类型
     */
    @PreAuthorize("@ss.hasPermi('recordtype:recordtype:edit')")
    @Log(title = "跟进类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Recordtype recordtype)
    {
        return toAjax(recordtypeService.updateRecordtype(recordtype));
    }

    /**
     * 删除跟进类型
     */
    @PreAuthorize("@ss.hasPermi('recordtype:recordtype:remove')")
    @Log(title = "跟进类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordTypeIds}")
    public AjaxResult remove(@PathVariable Long[] recordTypeIds)
    {
        return toAjax(recordtypeService.deleteRecordtypeByRecordTypeIds(recordTypeIds));
    }
}
